package com.dashboard.giangday;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.HashMap;
import com.lb.jwitter.connectDatabase.ConnectTTGD;
import com.opensymphony.xwork2.Action;

public class ListKhoa {
	private ArrayList<HashMap<String, String>> listKhoa;
	
	public ArrayList<HashMap<String, String>> getListKhoa() {
		return listKhoa;
	}
	public void setListKhoa(ArrayList<HashMap<String, String>> listKhoa) {
		this.listKhoa = listKhoa;
	}
	public String execute() throws Exception
	{
		ConnectTTGD conn= new ConnectTTGD();
		if(conn.getConnection()!=null){
			listKhoa=new ArrayList<HashMap<String, String>>();
			String query="select distinct maKhoa, tenKhoa from khoa_view where maKhoa is not null";
			HashMap<String,String> map;	
			ResultSet data=conn.getData(query);
			if(data!=null){
				while(data.next()){
					map = new HashMap<String,String>();
					String maKhoa=data.getString("maKhoa");
					String tenKhoa=data.getString("tenKhoa");
					map.put("ma", maKhoa);
					map.put("ten", tenKhoa);
					listKhoa.add(map);
				}
			}
			
		}
		conn.closeConnection();
		return Action.SUCCESS;

	}
}
